package transactionimplementation

import (
	"reflect"
	abstracttransaction "salarypayment-case/AbstractTransaction"
	Database "salarypayment-case/DataBase"
	"salarypayment-case/Model"
	"salarypayment-case/modelimplementation"
)


type ChangeUnaffiliatedTransaction struct {
	abstracttransaction.ChangeAffiliationTransaction
}

func (ct *ChangeUnaffiliatedTransaction) RecordMembership(e *Model.Employee) {
	af := e.GetAffiliation()
	if reflect.TypeOf(af) == reflect.TypeOf(modelimplementation.UnionAffiliation{}) {
		uaf := af.(*modelimplementation.UnionAffiliation)
		memberid := uaf.GetMemberId()
		Database.PayrollDatabases.RemoveUnionMember(memberid)
	}
}

func (ct *ChangeUnaffiliatedTransaction) GetAffiliation() Model.Affiliation {
	return &Model.NoAffiliation{}
}